evaluate a function given a graph